#!/usr/bin/env python
# coding=utf8

#
# 發送聚會通告
#
# Author: 幸延 <a0726h77@gmail.com>, Chun-Yu Lee (Mat) <matlinuxer2@gmail.com>
# Copyright: 幸延 <a0726h77@gmail.com> || Chun-Yu Lee (Mat) <matlinuxer2@gmail.com>
# License: MIT
#
import common
from Gmail import Gmail

common.read_settings_from_file()

PartyDate = common.thisThursday()


username = common.volatile_settings['username']
password = common.volatile_settings['password']
Sender = common.volatile_settings['who']  # 值日生的 email
Reciver = common.volatile_settings['email_address']
Subject = "HackingThursday 固定聚會 (" + PartyDate + ")"

# 這裡改從網頁上將通告內文抓下來，以後改用網頁來更新通告。
Html = common.get_wikidot_content_body("http://www.hackingthursday.org/invite")
Txt = common.html2txt(Html)

if __name__ == "__main__":
    receivers = Reciver.split(',')
    for item in receivers:
        receiver = item.strip()

        gmail = Gmail(username, password)
        gmail.send(Sender, receiver, Subject, Txt, Html)
